package com.depth.viewer.request.webservice
{
	import com.depth.viewer.request.RequestBaseProxy;
	
	public class WebServiceReuqest extends RequestBaseProxy
	{
		private var _service:WebServiceServcie;
		public function WebServiceReuqest(url:String = null)
		{
			super(url);
			super.request(null,null);
			if(url){
				_service = new WebServiceServcie(url);
				_service.resultHandle = resultEventHandle;
				_service.faultHandle = faultEventHane;
				_service.completeHandle = completeEventHandler;
				
			}
		}
		override public function set url(value:String):void{
			this._url = value;
			if(value && value.indexOf("http://") != -1){
				_service = new WebServiceServcie(url);
				_service.resultHandle = resultEventHandle;
				_service.faultHandle = faultEventHane;
			}
		}
		protected function resultEventHandle(data:Object):void{
			if(_resultHandle){
				if(_data)
					_resultHandle(data,_data);
				else
					_resultHandle(data);
			}
		}
		protected function faultEventHane(info:Object):void{
			if(_faultHandle){
				if(_data)
					_faultHandle(info,_data);
				else
					_faultHandle(info);
			}
		}
		
		protected function completeEventHandler():void{
			if(_completeHandle){
				_completeHandle(this);
			}
		}
		override public function request(methodName:String,... args:Array):void{
			super.request(methodName,args);
			_service.call(methodName,args);
		}
	}
}